<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<title>搜索页面</title>

		<!-- <link href="static/css/amazeui.css" rel="stylesheet" type="text/css" /> -->
		<link href="static/css/admin.css" rel="stylesheet" type="text/css" />

		<link href="static/css/demo.css" rel="stylesheet" type="text/css" />

		<link href="static/css/seastyle.css" rel="stylesheet" type="text/css" />

		<!-- element-ui引入 -->
     <!-- 引入样式 -->
	<link rel="stylesheet" href="static/css/element.css">

		<!-- element-ui需要引入vue.js -->
		<script src="static/js/vue.js"></script>
		<script src="static/js/vue.min.js"></script>
		<!-- 引入组件库 -->
<script src="static/js/element.js"></script>
<!--  -->


		<script type="text/javascript" src="static/js/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="static/js/script.js"></script>
	</head>

	<body>

		<div id="container">
<!--顶部导航条 -->
		<div class="am-container header">
			<ul class="message-l">
					
				<!-- <li>{{categories[0].categoryName}}</li> -->

			
				<div class="topMessage" >
					
					<div class="menu-hd" v-if="username!=null" style="color: teal;font-size: 20px;">
					{{username}},欢迎您
				   </div>
			<a href="login.html" style="color: red;font-size: 16px;">  退出系统</a>	 
					<div class="menu-hd" v-else>
						<a href="login.html" target="_top" class="h">亲，请登录</a>
						<a href="register.html" target="_top">免费注册</a>
					</div>
				</div>
			</ul>
			<ul class="message-r">
				<div class="topMessage home">
					<div class="menu-hd"><a href="index.html" target="_top" class="h">商城首页</a></div>
				</div>
				<div class="topMessage my-shangcheng">
					<div class="menu-hd MyShangcheng"><a href="#" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
				</div>
				<div class="topMessage mini-cart">
					<div class="menu-hd"><a id="mc-menu-hd" href="shopcart.html" target="_top"><i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum" class="h">0</strong></a></div>
				</div>
				<div class="topMessage favorite">
					<div class="menu-hd"><a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a></div>
			</ul>
			</div>

			<!--悬浮搜索框-->

			<div class="nav white">
				<div class="logo"><img src="static/images/threeMouse.jpg" style="border-radius: 50%;" /></div>
				<div class="logoBig">
					<li><img src="static/images/threeMouse.jpg" style="border-radius: 70%;" /></li>
				</div>

				<div class="search-bar pr">
					<a name="index_none_header_sysc" href="#"></a>
					<form>
						<input id="searchInput" v-model="keyword" name="keyword" type="text" @click="querySearch" placeholder="搜索" autocomplete="off">
						<input id="ai-topsearch" class="submit am-btn"  value="搜索" index="1" @click="setIntoStorage" type="submit">
					</form>
				</div>
			</div>

			<div class="clear"></div>
			<b class="line"></b>
           <div class="search">
			<div class="search-list">
			<div class="nav-table">
					   <div class="long-title"><span class="all-goods">全部分类</span></div>
					   <div class="nav-cont">
							<ul>
								<li class="index"><a href="index.html">首页</a></li>
                                <li class="qc"><a href="#">闪购</a></li>
                                <li class="qc"><a href="#">限时抢</a></li>
                                <li class="qc"><a href="#">团购</a></li>
                                <li class="qc last"><a href="#">大包装</a></li>
							</ul>
						    <div class="nav-extra">
						    	<i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的福利
						    	<i class="am-icon-angle-right" style="padding-left: 10px;"></i>
						    </div>
						</div>
			</div>
			
				
					<div class="am-g am-g-fixed">
						<div class="am-u-sm-12 am-u-md-12">
	                  	<div class="theme-popover">														
							<div class="searchAbout">
								<span class="font-pale">相关搜索：</span>
								<a title="坚果" href="#">坚果</a>
								<a title="瓜子" href="#">瓜子</a>
								<a title="鸡腿" href="#">豆干</a>

							</div>
							<ul class="select">
								<p class="title font-normal">
									<span class="fl">松子</span>
									<span class="total fl">搜索到<strong class="num">997</strong>件相关商品</span>
								</p>
								<div class="clear"></div>
								<li class="select-result">
									<dl>
										<dt>已选</dt>
										<dd class="select-no"></dd>
										<p class="eliminateCriteria">清除</p>
									</dl>
								</li>
								<div class="clear"></div>

							
	<li class="select-list">
									<dl id="select1">
										<dt class="am-badge am-round">品牌</dt>	
									
										 <div class="dd-conent">										
											<dd class="select-all selected"><a @click="all">全部</a></dd>	
											<!-- {{this.brands}} -->
											<template v-for="b,index in brands">
											 <dd><button @click="getProduct(b)"  >{{b}}</button></dd>	
											</template>
											<!--<dd><a href="#">良品铺子</a></dd>
											<dd><a href="#">新农哥</a></dd>
											<dd><a href="#">楼兰蜜语</a></dd>
											<dd><a href="#">口水娃</a></dd>
											<dd><a href="#">考拉兄弟</a></dd> -->
										 </div>
						
									</dl>
								</li>


							
<!-- 							
								<li class="select-list">
									<dl id="select2">
										<dt class="am-badge am-round">种类</dt>
										<div class="dd-conent">
											<dd class="select-all selected"><a href="#">全部</a></dd>
											<dd><a href="#">东北松子</a></dd>
											<dd><a href="#">巴西松子</a></dd>
											<dd><a href="#">夏威夷果</a></dd>
											<dd><a href="#">松子</a></dd>
										</div>
									</dl>
								</li>
								<li class="select-list">
									<dl id="select3">
										<dt class="am-badge am-round">选购热点</dt>
										<div class="dd-conent">
											<dd class="select-all selected"><a href="#">全部</a></dd>
											<dd><a href="#">手剥松子</a></dd>
											<dd><a href="#">薄壳松子</a></dd>
											<dd><a href="#">进口零食</a></dd>
											<dd><a href="#">有机零食</a></dd>
										</div>
									</dl>
								</li>
					         -->
							</ul>
							<div class="clear"></div>
                        </div>
							<div class="search-content">
								<div class="sort">
									<li class="first"><a title="综合">综合排序</a></li>
									<li><a title="销量" href="#" @click="orderBySoldNum">销量排序</a></li>
									<li><a title="价格" href="#" @click="orderByPrice">价格优先</a></li>
									<li class="big"><a title="评价" href="#">评价为主</a></li>
								</div>
								<div class="clear"></div>
           <template v-for="p in products">


	<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
									
								
								
									
									</li>
									
									<a href="introduction.html">	<li style="width: 200px; float: right;">
										<div class="i-pic limit">
											
											<img :src="'static/pimg/'+p.imgs[0].url " style="width:200px;"/>
											<p class="title fl">{{p.productName}}</p>
											<p class="price fl">
												<b>¥</b>
												<strong>3.5</strong>
											</p>
											<p class="number fl">
												销量<span>{{p.soldNum}}</span>
											</p>
										</div>
									</li>   </a>
								
									<!-- <li>
										<div class="i-pic limit">
											
											<img src="static/images/imgsearch1.jpg" />
											<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
											<p class="price fl">
												<b>¥</b>
												<strong>56.90</strong>
											</p>
											<p class="number fl">
												销量<span>1110</span>
											</p>
										</div>
									</li>
									<li>
										<div class="i-pic limit">
											
											<img src="static/images/imgsearch1.jpg" />
											<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
											<p class="price fl">
												<b>¥</b>
												<strong>56.90</strong>
											</p>
											<p class="number fl">
												销量<span>1110</span>
											</p>
										</div>
									</li>
									<li>
										<div class="i-pic limit">
											
											<img src="static/images/imgsearch1.jpg" />
											<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
											<p class="price fl">
												<b>¥</b>
												<strong>56.90</strong>
											</p>
											<p class="number fl">
												销量<span>1110</span>
											</p>
										</div>
									</li> -->
								</ul>



		   </template>


		   <template v-for="p in products1">


			<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
											
										
										
											
											</li>
											
											<a href="introduction.html">	<li style="width: 200px; float: right;">
												<div class="i-pic limit">
													
													<img :src="'static/pimg/'+p.skus[0].skuImg " style="width:200px;height: 200px;"/>
													<p class="title fl">【{{p.productName}}】 {{p.skus[0].skuName}}</p>
													<p class="price fl">
														<b>¥</b>
														<strong>{{p.skus[0].sellPrice}}</strong>
													</p>
													<p class="number fl">
														销量<span>{{p.soldNum}}</span>
													</p>
												</div>
											</li>   </a>
										
											
		
		
				   </template>
								
							

							</div>
							<!-- <div class="search-side">

								<div class="side-title">
									经典搭配
								</div>

								
								<li>
									<div class="i-pic check">
										<img src="static/images/cp.jpg" />
										<p class="check-title">萨拉米 1+1小鸡腿</p>
										<p class="price fl">
											<b>¥</b>
											<strong>29.90</strong>
										</p>
										<p class="number fl">
											销量<span>1110</span>
										</p>
									</div>
								</li>

							</div> -->
							<div class="clear"></div>
					

							<!-- 分页 -->
													<!-- 分页 -->
													<el-pagination
													background
													layout="prev, pager, next"
													:current-page="pageNum"
													:page-size="limit"
													:total="count">
												  </el-pagination>



							<!-- <ul class="am-pagination am-pagination-right">
								<li class="am-disabled"><a href="#">&laquo;</a></li>
								<li class="am-active"><a href="#">1</a></li>
								<li><a href="#">2</a></li>
								<li><a href="#">3</a></li>
								<li><a href="#">4</a></li>
								<li><a href="#">5</a></li>
								<li><a href="#">&raquo;</a></li>
							</ul> -->

						</div>
					</div>
					<div class="footer">
						<div class="footer-hd">
							<p>
								<a href="#">三只松鼠商城</a>
								<b>|</b>
								<a href="#">商城首页</a>
								<b>|</b>
								<a href="#">支付宝</a>
								<b>|</b>
								<a href="#">物流</a>
							</p>
						</div>
						<div class="footer-bd">
							<p>
								<a href="#">关于三只松鼠</a>
								<a href="#">合作伙伴</a>
								<a href="#">联系我们</a>
								<a href="#">网站地图</a>
								<em>©qfedu.com 版权所有</em>
							</p>
						</div>
					</div>
				</div>

			</div>

		<!--引导 -->
		<div class="navCir">
			<li><a href="home.html"><i class="am-icon-home "></i>首页</a></li>
			<li><a href="sort.html"><i class="am-icon-list"></i>分类</a></li>
			<li><a href="shopcart.html"><i class="am-icon-shopping-basket"></i>购物车</a></li>	
			<li><a href="person/index.html"><i class="am-icon-user"></i>我的</a></li>					
		</div>

		<!--菜单 -->
		<div class=tip>
			<div id="sidebar">
				<div id="wrap">
					<div id="prof" class="item">
						<a href="#">
							<span class="setting"></span>
						</a>
						<div class="ibar_login_box status_login">
							<div class="avatar_box">
								<p class="avatar_imgbox"><img src="static/images/no-img_mid_.jpg" /></p>
								<ul class="user_info">
									<li>用户名：sl1903</li>
									<li>级&nbsp;别：普通会员</li>
								</ul>
							</div>
							<div class="login_btnbox">
								<a href="#" class="login_order">我的订单</a>
								<a href="#" class="login_favorite">我的收藏</a>
							</div>
							<i class="icon_arrow_white"></i>
						</div>

					</div>
					<div id="shopCart" class="item">
						<a href="#">
							<span class="message"></span>
						</a>
						<p>
							购物车
						</p>
						<p class="cart_num">0</p>
					</div>
					<div id="asset" class="item">
						<a href="#">
							<span class="view"></span>
						</a>
						<div class="mp_tooltip">
							我的资产
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div id="foot" class="item">
						<a href="#">
							<span class="zuji"></span>
						</a>
						<div class="mp_tooltip">
							我的足迹
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div id="brand" class="item">
						<a href="#">
							<span class="wdsc"><img src="static/images/wdsc.png" /></span>
						</a>
						<div class="mp_tooltip">
							我的收藏
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div id="broadcast" class="item">
						<a href="#">
							<span class="chongzhi"><img src="static/images/chongzhi.png" /></span>
						</a>
						<div class="mp_tooltip">
							我要充值
							<i class="icon_arrow_right_black"></i>
						</div>
					</div>

					<div class="quick_toggle">
						<li class="qtitem">
							<a href="#"><span class="kfzx"></span></a>
							<div class="mp_tooltip">客服中心<i class="icon_arrow_right_black"></i></div>
						</li>
						<!--二维码 -->
						<li class="qtitem">
							<a href="#none"><span class="mpbtn_qrcode"></span></a>
							<div class="mp_qrcode" style="display:none;"><img src="static/images/weixin_code_145.png" /><i class="icon_arrow_white"></i></div>
						</li>
						<li class="qtitem">
							<a href="#top" class="return_top"><span class="top"></span></a>
						</li>
					</div>

					<!--回到顶部 -->
					<div id="quick_links_pop" class="quick_links_pop hide"></div>

				</div>

			</div>
			<div id="prof-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					我
				</div>
			</div>
			<div id="shopCart-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					购物车
				</div>
			</div>
			<div id="asset-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					资产
				</div>

				<div class="ia-head-list">
					<a href="#" target="_blank" class="pl">
						<div class="num">0</div>
						<div class="text">优惠券</div>
					</a>
					<a href="#" target="_blank" class="pl">
						<div class="num">0</div>
						<div class="text">红包</div>
					</a>
					<a href="#" target="_blank" class="pl money">
						<div class="num">￥0</div>
						<div class="text">余额</div>
					</a>
				</div>

			</div>
			<div id="foot-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					足迹
				</div>
			</div>
			<div id="brand-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					收藏
				</div>
			</div>
			<div id="broadcast-content" class="nav-content">
				<div class="nav-con-close">
					<i class="am-icon-angle-right am-icon-fw"></i>
				</div>
				<div>
					充值
				</div>
			</div>
		</div>


		</div>
<div class="theme-popover-mask"></div>
		
		<script>
			window.jQuery || document.write('<script src="static/js/jquery-1.9.min.js"><\/script>');
		</script>

<script src="static/js/cookie_utils.js"></script>
<script src="static/js/vue.min.js"></script>
<!-- <script src="https://unpkg.com/element-ui/lib/index.js"></script> -->
<script src="static/js/axios.min.js"></script>
<!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script> -->
<script src="static/js/utils.js"></script>

<script src="static/js/base.js"></script>

		<script type="text/javascript" src="static/js/quick_links.js"></script>
		

<script type="text/javascript">
    
var vm=new Vue({
	

	el:"#container",
	data:{
		// -----搜索历史记录
		srcOrderNoArr: [{
      value: '小', // 这个必须要有
      type: ''
    },
    {
      value: '加力加',
      type: ''
    },
    {
      value: '',
      type: ''
    }],


		// -----
		cid:"",
		username:"",
		products:[],
		products1:[],
		//品牌名字
		brand:"",
		//品牌数组
		brands:[],
		keyword:"",
		limit:11,
		pageNum:1,
		count:5

	},
	methods: {
		orderBySoldNum(){
         var url7=baseUrl+"product/listOrderByProducSkutSoldNum";
		 axios({
			 url:url7,
			 method:"get"
		 }).then((res)=>{
		 this.products1=res.data.data;
		 this.products=res.data.data;


		 console.log("商品销量进行排序--------");
		 console.log(res.data.data);
		 });




		},
		orderByPrice(){
			var url8=baseUrl+"product/listOrderByProducSkutSellPrice";

			axios({
			 url:url8,
			 method:"get"
		 }).then((res)=>{
			this.products=res.data.data;

			console.log(res.data.data.data);
		 });

		},


		pager(){
			var url1=baseUrl+"product/listbycid/+"+49;
        axios({
			url:url1,
			method:"get",
			params:{
				
				pageNum:this.pageNum,
				limit:this.limit

			}
		}).then((res)=>{
			console.log("商品分类id查询商品信息--------");

			this.products1=res.data.data.data;
			this.count=res.data.data.count;
			console.log(res.data.data.data);

		});

	


		},
		//根据品牌的名字进行查询商品信息
		getProduct(index){
			console.log(index);

			var url6=baseUrl+"product/listProductsByBrand";
			axios({
				url:url6,
				method:"get",
				params:{
					brand:index
				}
			}).then((res)=>{
				this.products1=res.data.data;

				console.log(res.data.data);
			});


		},
		// 查询全部
		all(){
			var url1=baseUrl+"product/listbycid/+"+49;
        axios({
			url:url1,
			method:"get",
			params:{
				
				pageNum:this.pageNum,
				limit:this.limit

			}
		}).then((res)=>{
			console.log("商品分类id查询商品信息--------");

			this.products1=res.data.data.data;
			this.count=res.data.data.count;
			console.log(res.data.data.data);

		});







		},
       

		// 历史搜索记录查询

		/**
   * 把搜索记录存入localStorage
   */
   setIntoStorage (type) {
   let self = this
   let noArr = [], // 订单号历史记录数组
    text = '', value = ''
   switch (type) {
    case 'srcOrderNo':
     text = 'srcOrderNoArr'
     value = self.srcOrderNo
     break
    case 'jobOrderNo':
     text = 'jobOrderNoArr'
     value = self.jobOrderNo
     break
    case 'cntNo':
     text = 'cntNoArr'
     value = self.cntNo
     break
    default:
     break
   }
   noArr.push({value: value, type: type})
   if(JSON.parse(localStorage.getItem(text))) { // 判断是否已有xxx查询记录的localStorage
    if(localStorage.getItem(text).indexOf(value) > -1 ) { // 判断是否已有此条查询记录，若已存在，则不需再存储
     return
    }
    if(JSON.parse(localStorage.getItem(text)).length >= 5) {
     let arr = JSON.parse(localStorage.getItem(text))
     arr.pop()
     localStorage.setItem(text, JSON.stringify(arr))
    }
    localStorage.setItem(text, JSON.stringify(noArr.concat(JSON.parse(localStorage.getItem(text)))))
   }
   else { // 首次创建
    localStorage.setItem(text, JSON.stringify(noArr))
   }
  },
   /**
 * 建议列表
 */
querySearch(queryString, cb) {
 // 调用 callback 返回建议列表的数据
 cb(JSON.parse(localStorage.getItem('srcOrderNoArr')));
 var url2=baseUrl+"product/listbykeywords";
		// aixo.get({}) 
		axios({
			url:url2,
			method:"get",
			params:{
				keyword:this.keyword,
				limit:this.limit,
				pageNum:this.pageNum

			}

		}).then(res=>{
			this.products=res.data.data.data;
			this.count=res.data.data.count;
			// console.log("商品关键字查询的信息-----");
			// console.log(res.data.data.data);

		});

},
},
	created(){

		this.querySearch();
// 搜索历史

               
    this.historyWord=localStorage.getItem('searchWord')
    this.historyWord=this.historyWord.split(',')  //将字符串转成数组






// ----------






		//获取商品分类id
		this.cid=getUrlParm("cid");
		console.log("---"+this.cid);

		if(this.cid!=null){
			var url1=baseUrl+"product/listbycid/+"+49;
        axios({
			url:url1,
			method:"get",
			params:{
				
				pageNum:this.pageNum,
				limit:this.limit

			}
		}).then((res)=>{
			console.log("商品分类id查询商品信息--------");

			this.products1=res.data.data.data;
			this.count=res.data.data.count;
			console.log(res.data.data.data);

		});




		if(keyword!=null){
				// 关键字查询品牌
		var url3=baseUrl+"product/listBrandbykeywords";
		axios({
			url:url3,
			method:"get",
			params:{
				keyword:this.keyword,
			}


		}).then((res)=>{
			this.brands=res.data.data;
          console.log(res.data.data);

		})





		} 
		var url5=baseUrl+"product/listBrandbycid/"+49;

		axios({
			url:url5,
			method:"get",
			
		}).then((res)=>{

			console.log("商品品牌信息------")
			console.log(res.data.data);
			this.brands=res.data.data;
		});


		}
		this.username=getCookieValue("username");
		console.log(this.username);
		var keyword=getUrlParm("keyword");
		this.keyword=keyword;
		// console.log("商品关键字信息--------");
		// console.log(this.keyword);
		
 
	    if(this.keyword!=null){

		var url2=baseUrl+"product/listbykeywords";
		// aixo.get({}) 
		axios({
			url:url2,
			method:"get",
			params:{
				keyword:this.keyword,
				limit:this.limit,
				pageNum:this.pageNum

			}

		}).then(res=>{
			this.products=res.data.data.data;
			this.count=res.data.data.count;
			// console.log("商品关键字查询的信息-----");
			// console.log(res.data.data.data);

		});



	
		}

	},
	



})

</script>

	</body>

</html>